%========================================================================
% This file reorganize the codes into two subfolders: benchmark and entry
% benchmark folder contains codes for the benchmarket model
% entry folder contains codes for the entry model with imperfect
% competition in the lending market
% Files in the two folders are named in the exactly same way
% The difference is that they
%=========================================================================

clear;
mkdir benchmark
mkdir entry
movefile entry* entry
movefile benchmark* benchmark
copyfile('*.csv','benchmark')
copyfile('*.csv','entry')


% rename files in the benchmark folder
cd benchmark
mkdir figures
mkdir intermediate_results
mfiles = dir('*.m');
for i = 1:length(mfiles)
    oldname = mfiles(i).name;
    newname = oldname(11:end);
    movefile(oldname,newname)
end

textfiles = dir('*.txt');
for i = 1:length(textfiles)
    oldname = textfiles(i).name;
    newname = oldname(11:end);
    movefile(oldname,newname)
end

matfiles = dir('*.mat');
for i = 1:length(matfiles)
    oldname = matfiles(i).name;
    newname = oldname(11:end);
    movefile(oldname,newname)
end


% rename files in the entry folder
cd ..
cd entry
mfiles = dir('*.m');
for i = 1:length(mfiles)
    oldname = mfiles(i).name;
    newname = oldname(7:end);
    movefile(oldname,newname)
end

textfiles = dir('*.txt');
for i = 1:length(textfiles)
    oldname = textfiles(i).name;
    newname = oldname(7:end);
    movefile(oldname,newname)
end

matfiles = dir('*.mat');
for i = 1:length(matfiles)
    oldname = matfiles(i).name;
    newname = oldname(7:end);
    movefile(oldname,newname)
end
mkdir figures
mkdir intermediate_results
cd ..
